package com.ruoyi.sale.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.sale.mapper.SaleOrderMapper;
import com.ruoyi.sale.domain.SaleOrder;
import com.ruoyi.sale.service.ISaleOrderService;
import com.ruoyi.common.core.text.Convert;

/**
 * 销售订单主Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-06-18
 */
@Service
public class SaleOrderServiceImpl implements ISaleOrderService 
{
    @Autowired
    private SaleOrderMapper saleOrderMapper;

    /**
     * 查询销售订单主
     * 
     * @param orderId 销售订单主主键
     * @return 销售订单主
     */
    @Override
    public SaleOrder selectSaleOrderByOrderId(Long orderId)
    {
        return saleOrderMapper.selectSaleOrderByOrderId(orderId);
    }

    /**
     * 查询销售订单主列表
     * 
     * @param saleOrder 销售订单主
     * @return 销售订单主
     */
    @Override
    public List<SaleOrder> selectSaleOrderList(SaleOrder saleOrder)
    {
        return saleOrderMapper.selectSaleOrderList(saleOrder);
    }

    /**
     * 新增销售订单主
     * 
     * @param saleOrder 销售订单主
     * @return 结果
     */
    @Override
    public int insertSaleOrder(SaleOrder saleOrder)
    {
        saleOrder.setCreateTime(DateUtils.getNowDate());
        return saleOrderMapper.insertSaleOrder(saleOrder);
    }

    /**
     * 修改销售订单主
     * 
     * @param saleOrder 销售订单主
     * @return 结果
     */
    @Override
    public int updateSaleOrder(SaleOrder saleOrder)
    {
        saleOrder.setUpdateTime(DateUtils.getNowDate());
        return saleOrderMapper.updateSaleOrder(saleOrder);
    }

    /**
     * 批量删除销售订单主
     * 
     * @param orderIds 需要删除的销售订单主主键
     * @return 结果
     */
    @Override
    public int deleteSaleOrderByOrderIds(String orderIds)
    {
        return saleOrderMapper.deleteSaleOrderByOrderIds(Convert.toStrArray(orderIds));
    }

    /**
     * 删除销售订单主信息
     * 
     * @param orderId 销售订单主主键
     * @return 结果
     */
    @Override
    public int deleteSaleOrderByOrderId(Long orderId)
    {
        return saleOrderMapper.deleteSaleOrderByOrderId(orderId);
    }
}
